package protocol.JT808_2011;

import java.util.HashMap;

public class Handle808_2011JT89 implements IHandle808_2011JT {
    @Override
    public String handle(JT808_2011Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x00:
                return handle8900(cmd);
            default:
                return "808-2011:未匹配的命令字"+(cmd.readOrder());
        }
    }

    private String handle8900(JT808_2011Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:数据下行透传");
        builder.append("\r\n");

        HashMap<Integer,String> list = new HashMap<>();
        list.put(0,"GNSS模块详细定位数据");
        list.put(0x0B,"道路运输卡IC卡信息");
        list.put(0x41,"串口1透传");
        list.put(0x42,"串口2透传");

        int type = cmd.readInt();
        builder.append("透传消息类型("+type+"):"+list.getOrDefault(type,"未定义"));
        builder.append("\r\n");

        builder.append("透传消息内容:"+cmd.readBCD(cmd.leftSize()));
        builder.append("\r\n");

        return builder.toString();
    }
}
